[IA64] Map shared_info into guest pseudo physical address space
authorawilliam@xenbuild2.aw <awilliam@xenbuild2.aw>
Thu, 7 Dec 2006 21:49:00 +0000 (14:49 -0700)
committerawilliam@xenbuild2.aw <awilliam@xenbuild2.aw>
Thu, 7 Dec 2006 21:49:00 +0000 (14:49 -0700)
Allows libxc to map from dom0. This is used by domain builder.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/xc_linux_build.c
xen/arch/ia64/xen/dom0_ops.c
xen/include/asm-ia64/grant_table.h

index 104a90d9916ffa37d1258eacb2ac84ab6d756749..8ddb1ed5257e5b048294d0d79f44cc7ace0cd28c 100644 (file)
@@ -481,9 +481,7 @@ static int setup_guest(int xc_handle,
     start_info_t *start_info;
     unsigned long start_info_mpa;
     struct xen_ia64_boot_param *bp;
-#if 0 // see comment below
     shared_info_t *shared_info;
-#endif
     int i;
     DECLARE_DOMCTL;
     int rc;
@@ -595,13 +593,20 @@ static int setup_guest(int xc_handle,
     ctxt->user_regs.r28 = start_info_mpa + sizeof (start_info_t);
     munmap(start_info, PAGE_SIZE);
 
-#if 0
     /*
-     * XXX FIXME:
-     * The follwoing initialization is done by XEN_DOMCTL_arch_setup as
-     * work around.
-     * Should XENMEM_add_to_physmap with XENMAPSPACE_shared_info be used?
+     * shared_info is assiged into guest pseudo physical address space
+     * by XEN_DOMCTL_arch_setup. shared_info_frame is stale value until that.
+     * So passed shared_info_frame is stale. obtain the right value here.
      */
+    domctl.cmd = XEN_DOMCTL_getdomaininfo;
+    domctl.domain = (domid_t)dom;
+    if ( (xc_domctl(xc_handle, &domctl) < 0) ||
+         ((uint16_t)domctl.domain != dom) )
+    {
+        PERROR("Could not get info on domain");
+        goto error_out;
+    }
+    shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
 
     /* shared_info page starts its life empty. */
     shared_info = xc_map_foreign_range(
@@ -615,7 +620,6 @@ static int setup_guest(int xc_handle,
     shared_info->arch.start_info_pfn = nr_pages - 3;
 
     munmap(shared_info, PAGE_SIZE);
-#endif
     free(page_array);
     return 0;
 
index 18c2e2f88e17949ea13afb594bf7ae3a1d298bbd..472f03dc54ae1269af6ed303575f03fc4956755e 100644 (file)
@@ -125,19 +125,19 @@ long arch_do_domctl(xen_domctl_t *op, XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
                     for_each_vcpu (d, v)
                         v->arch.breakimm = d->arch.breakimm;
                 }
-#if 1
-                /*
-                 * XXX FIXME 
-                 * see comment around shared_info in setup_guest() in 
-                 * libxc/xc_linux_build.c
-                 */
                 {
-                    int i;
-                    d->shared_info->arch.start_info_pfn = ds->maxmem >> PAGE_SHIFT;
-                    for_each_cpu(i)
-                        d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
+                    /*
+                     * XXX IA64_SHARED_INFO_PADDR
+                     * assign these pages into guest psudo physical address
+                     * space for dom0 to map this page by gmfn.
+                     * this is necessary for domain build, save, restore and 
+                     * dump-core.
+                     */
+                    unsigned long i;
+                    for (i = 0; i < XSI_SIZE; i += PAGE_SIZE)
+                        assign_domain_page(d, IA64_SHARED_INFO_PADDR + i,
+                                           virt_to_maddr(d->shared_info + i));
                 }
-#endif
             }
         }
 
index 1d0bded64f672371a850ad4bd600aca11869ecd9..895d1ee936638199611156bcb01d4c81e45f1916 100644 (file)
@@ -23,8 +23,16 @@ void guest_physmap_add_page(struct domain *d, unsigned long gpfn, unsigned long
     } while (0)
 
 
+/* XXX
+ * somewhere appropriate
+ * those constand shouldn't be pre-defined and
+ * those area should be reserved by EFI MD.
+ */
+/* Guest phsyical address of shared_info */
+#define IA64_SHARED_INFO_PADDR (1UL << 40)
+
 /* Guest physical address of the grant table.  */
-#define IA64_GRANT_TABLE_PADDR (1UL << 40)
+#define IA64_GRANT_TABLE_PADDR  (IA64_SHARED_INFO_PADDR + XSI_SIZE)
 
 #define gnttab_shared_maddr(d, t, i)                        \
     virt_to_maddr((char*)(t)->shared + ((i) << PAGE_SHIFT))